#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
/*定义资源*/
static struct resource my_device_resource[]=
{
	[0] = {
		.start = 0xFDD6000,
		.end = 	 0xFDD60004,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = 13,
		.end = 13,
		.flags = IORESOURCE_IRQ,	
	}
};
/*必须要用到的release函数*/
void my_device_release(struct device *dev){
	printk("This is my_device_release\n");
	return;
}

/*定义个一platform_device*/
 struct platform_device platfrom_device_test = {
	.name = "my_platform_test",
	.id = -1,
	.resource = my_device_resource,
	.num_resources = ARRAY_SIZE(my_device_resource),
	.dev = {
		.release = my_device_release,
	},
};

 
/* 驱动入口函数 */
static int  platform_init(void) {
	printk("This is platform_init\n");
	/*加载platform*/
	platform_device_register(&platfrom_device_test);
	return 0;
	
}
 
/* 驱动出口函数 */
static void  platform_exit(void)	{
	printk("This is platform_exit\n");
	platform_device_unregister(&platfrom_device_test);
}
module_init(platform_init);	/*指定设备驱动入口函数*/
module_exit(platform_exit);	/*指定设备驱动出口函数*/
MODULE_LICENSE("GPL");
